package com.touni.designpattern.abstractfactorypattern;

import com.touni.designpattern.abstractfactorypattern.abfactory.AbstractFactory;
import com.touni.designpattern.abstractfactorypattern.abfactory.ColorFactory;
import com.touni.designpattern.abstractfactorypattern.abfactory.ShapeFactory;

/**
 * @ClassName : FactoryProducer
 * @Description : '
 * @Author : lwq
 * @Date: 2020-10-19 09:29
 */
public class FactoryProducer {
    public static AbstractFactory getAbFactory(String factoryName){
        if (factoryName == null){
            throw new RuntimeException("factoryName must not be null!!");
        }else if (factoryName.equalsIgnoreCase("shape")){
            return new ShapeFactory();
        }else if (factoryName.equalsIgnoreCase("color")){
            return new ColorFactory();
        }else {
            throw new RuntimeException("no such factory!!");
        }
    }

}
